package com.device.grant.dao.impl;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.stereotype.Repository;

import com.device.grant.dao.ApparatusGroupDao;
import com.device.grant.dao.BaseDao;
import com.device.grant.pojo.ApparatusGroup;
import com.device.grant.utils.ColumnCompator;
import com.device.grant.utils.SQLUtils2;

@Repository("apparatusGroupDao")
public class ApparatusGroupDaoImpl extends BaseDao<ApparatusGroup> implements ApparatusGroupDao {

    public static final String TABLE = "ApparatusGroup";

    public static final String ID = "appGroupCode";

    public List<ApparatusGroup> getApparatusGroup(Integer page, Integer rows, Map<String, Object> params,
            List<String> blearParams, Map<String, ColumnCompator> compators, String orderBy) {
        String sql = SQLUtils2.genearlQuerySQLForCompareAndNotIn(TABLE, ID, page, rows, params, blearParams, compators, orderBy);

        return super.queryInSQL(sql);
    }

    public boolean insertApparatusGroup(ApparatusGroup apparatusGroup) {
        return super.insert(TABLE, ID, apparatusGroup);
    }

    public Integer countApparatusGroup(Map<String, Object> conditions, List<String> blearParams,
            Map<String, ColumnCompator> compators) {
        Map<String, Object> map = SQLUtils2.generalCountSQLForCompare(TABLE, ID, conditions, blearParams, compators);

        return simpleJdbcTemplate.queryForInt(map.get(SQLUtils2.SQL).toString(), (Object[]) map.get(SQLUtils2.PARAMS));
    }

    public boolean updateApparatusGroup(Map<String, Object> changeInfos, Map<String, Object> conditions) {
        return super.update(TABLE, changeInfos, conditions);
    }

    public List<ApparatusGroup> queryApparatusGroupsInIds(Set<Integer> ids) {
        return super.queryInKeys(TABLE, ID, null, ids);
    }

    public List<ApparatusGroup> queryApparatusGroup() {
        return super.queryAll(TABLE, null);
    }
}
